package com.wang.tank;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

/**
 * @author 王先锋
 * @version 1.0
 */
public class HspTankGame01 extends JFrame {
    //定义Mypanel
    MyPanel mp = null;
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        HspTankGame01 hsptankgame01 = new HspTankGame01();
    }

    public HspTankGame01() {
        System.out.println("请输入1:新游戏 2：上局游戏");
        String key=scanner.next();
        mp = new MyPanel(key);
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);
        this.addKeyListener(mp);
        this.setSize(1300, 750);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        //在JFrame中增加监听
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent windowEvent) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }


}
